﻿using MMPS.Entity.POCOMdel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MMPS.Common;
using MMPS.Entity.ViewModel;

namespace MMPS.Business
{
   public  class OrderService:BaseService<ConsumeOrders>
    {
        public OperateResult ConOrderList(string CardORmobile,MemCardsOrderListViewModel viewModel)
        {
            var query = PredicateExtensions.True<ConsumeOrders>();
            //判断会员卡号或手机号是否为空
            if (!string.IsNullOrWhiteSpace(CardORmobile))
            {
                query = query.And(c=>c.MemCards.MC_CardID== CardORmobile||c.MemCards.MC_Mobile== CardORmobile);
            }
            int rowsCount = 0;
            var mod = GetList(viewModel.page, viewModel.rows, ref rowsCount, query, c => c.CO_ID, true).Select(c => new MemCardsOrderListViewModel
            {
                MC_CardID = c.MC_CardID,
                MC_Name = c.MemCards.MC_Name,
                CO_CreateTime = c.CO_CreateTime.ToString(),
                CO_DiscountMoney = c.CO_DiscountMoney.ToString(),
                CO_GavePoint = (int)c.CO_GavePoint,
                CO_OrderCode = c.CO_OrderCode,
                CO_OrderType = (byte)c.CO_OrderType,
                CO_Recash = (float)c.CO_Recash,
                CO_TotalMoney = (float)c.CO_TotalMoney,
                MC_Mobile = c.MemCards.MC_Mobile,

            }).ToList();
            var dataList = new DatgRIDViewModel { rows= mod , total= rowsCount };
            return new OperateResult(ResultStatus.Success, "", dataList);
        }
    }
}
